namespace Terra.Core.Common.ErrorCodes.Constants;

using Terra.Core.Common.ErrorCodes.Attributes;
using Terra.Core.Common.ErrorCodes.Models;

/// <summary>
/// 数据错误码
/// </summary>
public static class DataErrorCodes
{
    /// <summary>
    /// 数据不存在
    /// </summary>
    [ErrorCode("DAT001", "数据不存在: {0}", Severity = ErrorSeverity.Error)]
    public const string NotFound = "DAT001";

    /// <summary>
    /// 数据已存在
    /// </summary>
    [ErrorCode("DAT002", "数据已存在: {0}", Severity = ErrorSeverity.Error)]
    public const string AlreadyExists = "DAT002";

    /// <summary>
    /// 数据已被删除
    /// </summary>
    [ErrorCode("DAT003", "数据已被删除: {0}", Severity = ErrorSeverity.Error)]
    public const string Deleted = "DAT003";

    /// <summary>
    /// 数据版本冲突
    /// </summary>
    [ErrorCode("DAT004", "数据已被其他用户修改，请刷新后重试", Severity = ErrorSeverity.Error)]
    public const string VersionConflict = "DAT004";

    /// <summary>
    /// 数据库连接失败
    /// </summary>
    [ErrorCode("DAT005", "数据库连接失败", Severity = ErrorSeverity.Critical)]
    public const string ConnectionFailed = "DAT005";

    /// <summary>
    /// 数据库查询超时
    /// </summary>
    [ErrorCode("DAT006", "数据库查询超时", Severity = ErrorSeverity.Error)]
    public const string QueryTimeout = "DAT006";

    /// <summary>
    /// 数据完整性约束违反
    /// </summary>
    [ErrorCode("DAT007", "数据完整性约束违反: {0}", Severity = ErrorSeverity.Error)]
    public const string IntegrityViolation = "DAT007";

    /// <summary>
    /// 数据类型转换失败
    /// </summary>
    [ErrorCode("DAT008", "数据类型转换失败: {0}", Severity = ErrorSeverity.Error)]
    public const string TypeConversionFailed = "DAT008";

    /// <summary>
    /// 数据访问权限不足
    /// </summary>
    [ErrorCode("DAT009", "没有权限访问该数据", Severity = ErrorSeverity.Error)]
    public const string AccessDenied = "DAT009";

    /// <summary>
    /// 数据状态无效
    /// </summary>
    [ErrorCode("DAT010", "当前状态 {0} 不允许执行 {1} 操作", Severity = ErrorSeverity.Error)]
    public const string InvalidState = "DAT010";

    /// <summary>
    /// 批量操作部分失败
    /// </summary>
    [ErrorCode("DAT011", "批量操作部分失败: 成功 {0} 条，失败 {1} 条", Severity = ErrorSeverity.Warning)]
    public const string BatchPartialFailure = "DAT011";

    /// <summary>
    /// 数据库死锁
    /// </summary>
    [ErrorCode("DAT012", "数据库死锁，请重试", Severity = ErrorSeverity.Error)]
    public const string Deadlock = "DAT012";
}